<?php
/**
 * Created by PhpStorm.
 * User: zhangrxiang
 * Date: 17-2-22
 * Time: 上午11:07
 */


function ref(&$arr)
{
    if (is_array($arr)) {
        foreach ($arr as $item => $value) {
            $arr[$item] = $value * $value;
        }
    } else {
        $arr = null;
    }
}

$a = [1, 2, 3];
ref($a);
print_r($a);




function defaultValue($default = PHP_EOL."wocao".PHP_EOL){
    return $default;
}

echo defaultValue();
echo defaultValue("");
echo defaultValue("test");


function defaultValue2(array $arr = [1,2,3],bool $flag = null, string $test = ''){
    if ($flag){
        print_r($arr);
    }else {

    }
    echo 'test---'.$test;
    echo 'flag---'.$flag;
}

defaultValue2([3,2,1]);
defaultValue2([3,2,1], $flag = true, $test = 'test');


function defaultValue3($flag, array &$a = [1,2,3]){
    if ($flag){
        print_r($a);
    }
}

$arr = [3,2,1];
defaultValue3(true,$arr);
defaultValue3(true);


//Type	Description	Minimum PHP version
//Class/interface name	The parameter must be an instanceof the given class or interface name.	PHP 5.0.0
//array	The parameter must be an array.	PHP 5.1.0
//callable	The parameter must be a valid callable.	PHP 5.4.0
//bool	The parameter must be a boolean value.	PHP 7.0.0
//float	The parameter must be a floating point number.	PHP 7.0.0
//int	The parameter must be an integer.	PHP 7.0.0
//string	The parameter must be a string. PHP 7.0.0

